﻿using Microsoft.AspNetCore.Http;
using mozhi.smarterp.Finance.Files.Services;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;

namespace mozhi.smarterp.Finance.Files
{
    public class FileAppService : FinanceAppService, IFileAppService
    {
        public FileManager _fileManager;

        public FileAppService(FileManager fileManager)
        {
            _fileManager = fileManager;
        }



        public async Task<FileDto> UploadFileAsync(IFormFile formFile)
        {
            var file = await _fileManager.CreateAsync(formFile);

            return ObjectMapper.Map<File , FileDto>(file);
        }

        public async Task<Tuple<Stream, string , string>> DownloadFileAsync(Guid id)
        {
            var result = await _fileManager.DownloadFileAsync(id);

            return result;
        }
    }
}
